#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 - 2013 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1

#include <Macros.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Models/Marketmodels/Models/PiecewiseConstantVariance.h>
#pragma unmanaged 
#include <ql\models\marketmodels\models\piecewiseconstantabcdvariance.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;
using namespace Cephei::Core;
using namespace PLATFORM::Collections;

#undef HANDLE
#undef ABSTRACT
#define STRUCT
namespace Cephei { namespace QL { namespace Models { namespace Marketmodels { namespace Models {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IPiecewiseConstantAbcdVariance
	public ref class CPiecewiseConstantAbcdVariance  : 
            public CPiecewiseConstantVariance,
            public Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance
	{
	protected: 
		boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>* _ppPiecewiseConstantAbcdVariance;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>* _phPiecewiseConstantAbcdVariance;
#endif
		Object^ _PiecewiseConstantAbcdVarianceOwner;     // reference to object that manages the storage for this object
	internal:
		CPiecewiseConstantAbcdVariance (Double a, Double b, Double c, Double d, UInt64 resetIndex, Cephei::Core::IVector<Double>^ rateTimes);
        CPiecewiseConstantAbcdVariance (boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>& childNative, Object^ owner);
        CPiecewiseConstantAbcdVariance (QuantLib::PiecewiseConstantAbcdVariance& childNative, Object^ owner);
        CPiecewiseConstantAbcdVariance (CPiecewiseConstantAbcdVariance^ copy);
        CPiecewiseConstantAbcdVariance (PLATFORM::Type^ t);
#ifdef STRUCT
        CPiecewiseConstantAbcdVariance (QuantLib::PiecewiseConstantAbcdVariance childNative);
#endif       
#ifdef HANDLE
		CPiecewiseConstantAbcdVariance (QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>& childNative, Object^ owner);
		CPiecewiseConstantAbcdVariance (QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance> childNative);
#endif
		virtual ~CPiecewiseConstantAbcdVariance ();
		!CPiecewiseConstantAbcdVariance ();

	internal:
		QuantLib::PiecewiseConstantAbcdVariance& GetReference ();
		boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>& GetShared ();
		QuantLib::PiecewiseConstantAbcdVariance* GetPointer ();
        void SetPiecewiseConstantAbcdVariance (boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance> native)
        {
            if (_ppPiecewiseConstantAbcdVariance != NULL)
                delete _ppPiecewiseConstantAbcdVariance;
            _ppPiecewiseConstantAbcdVariance = new boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance> (native);
            SetPiecewiseConstantVariance (boost::dynamic_pointer_cast<QuantLib::PiecewiseConstantVariance> (*_ppPiecewiseConstantAbcdVariance));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
		virtual Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^ GetABCD (Double a, Double b, Double c, Double d) ;
        property Cephei::Core::IVector<Double>^ RateTimes 
        {
		    virtual Cephei::Core::IVector<Double>^ get () ;
        }
        property Cephei::Core::IVector<Double>^ Variances 
        {
		    virtual Cephei::Core::IVector<Double>^ get () ;
        }
        property Cephei::Core::IVector<Double>^ Volatilities 
        {
		    virtual Cephei::Core::IVector<Double>^ get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IPiecewiseConstantAbcdVariance Vector interface
	ref class CPiecewiseConstantAbcdVarianceVector sealed : 
							    public Core::INativeVector<IPiecewiseConstantAbcdVariance^>,
							    public Core::INativeVector<Core::Generic::ICoCell<IPiecewiseConstantAbcdVariance^>^>
	{
	private:
#ifdef STRUCT
		std::vector<QuantLib::PiecewiseConstantAbcdVariance>* _pVValue;
#endif        
		std::vector<boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>>* _pVBoost;
#ifdef HANDLE
		std::vector<QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>>* _pVHand;
#endif
		Object^ _owner;		// object reference to prevent GC of vector owner

	internal:
		CPiecewiseConstantAbcdVarianceVector ();
#ifdef STRUCT
		CPiecewiseConstantAbcdVarianceVector (std::vector<QuantLib::PiecewiseConstantAbcdVariance>& vec, Object^ owner);
		CPiecewiseConstantAbcdVarianceVector (std::vector<QuantLib::PiecewiseConstantAbcdVariance> vec);
#endif       
		CPiecewiseConstantAbcdVarianceVector (std::vector<boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>>& vec, Object^ owner);
#ifdef HANDLE
		CPiecewiseConstantAbcdVarianceVector (std::vector<QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>>& vec, Object^ owner);
#endif
		virtual ~CPiecewiseConstantAbcdVarianceVector ();
		!CPiecewiseConstantAbcdVarianceVector ();

    public:
		property int Count 
		{
			virtual int get ();
		}

		property IPiecewiseConstantAbcdVariance^ default[int] 
		{
			virtual IPiecewiseConstantAbcdVariance^ get (int index) = Core::INativeVector<IPiecewiseConstantAbcdVariance^>::default::get;
			virtual void set (int index, IPiecewiseConstantAbcdVariance^ value) = Core::INativeVector<IPiecewiseConstantAbcdVariance^>::default::set;
		}

		//////////////////////////////////////////////////////////////////////////////////////////
		// Interface functions for cell vectors 
	public:
		property Core::Generic::ICoCell<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^ CItem[int] 
		{
			virtual Core::Generic::ICoCell<IPiecewiseConstantAbcdVariance^>^ get (int index) = Core::INativeVector<Core::Generic::ICoCell<IPiecewiseConstantAbcdVariance^>^>::default::get;
			virtual void set (int index, Core::Generic::ICoCell<IPiecewiseConstantAbcdVariance^>^ value) = Core::INativeVector<Core::Generic::ICoCell<IPiecewiseConstantAbcdVariance^>^>::default::set;
		}
	internal:
#ifdef STRUCT    
		std::vector<QuantLib::PiecewiseConstantAbcdVariance>& GetReference ();
#endif     
		std::vector<boost::shared_ptr<QuantLib::PiecewiseConstantAbcdVariance>>& GetShared ();

#ifdef HANDLE
		std::vector<QuantLib::Handle<QuantLib::PiecewiseConstantAbcdVariance>>& GetHandle ();
#endif
	public:
		virtual bool PrepareFeature (NativeFeature feature);
	};
    
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
//z	[FactoryFor(Core::Generic::ICoCell<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>::typeid)]
	[FactoryFor(Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance::typeid)]
	[FactoryFor(Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance_Factory::typeid)]
	public ref class CPiecewiseConstantAbcdVariance_Factory sealed : public IPiecewiseConstantAbcdVariance_Factory
	{
	public:
        virtual IPiecewiseConstantAbcdVariance^ Create (Double a, Double b, Double c, Double d, UInt64 resetIndex, Cephei::Core::IVector<Double>^ rateTimes);
        /* <summary> Create a hybrid Vector of IPiecewiseConstantAbcdVariance, with event notification of changes </summary> */
        virtual Cephei::Core::IVector<IPiecewiseConstantAbcdVariance^>^ CreateVector();
        /* <summary> Create a hybrid Vector of ICell of IPiecewiseConstantAbcdVariance, with event notification of changes </summary> */
        virtual Core::Generic::ICoCell<Cephei::Core::IVector<Core::Generic::ICoCell<IPiecewiseConstantAbcdVariance^>^>^>^ CreateCellVector();
        virtual Cephei::Core::IVector<IPiecewiseConstantAbcdVariance^>^ CreateVector(PLATFORM::Collections::Generic::IEnumerable<IPiecewiseConstantAbcdVariance^>^ source);
        virtual Core::Generic::ICoCell<Cephei::Core::IVector<Core::Generic::ICoCell<IPiecewiseConstantAbcdVariance^>^>^>^ CreateCellVector(PLATFORM::Collections::Generic::IEnumerable<Core::Generic::ICoCell<IPiecewiseConstantAbcdVariance^>^>^ source);
		virtual Core::INativeVector<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^ CreateNativeVector ()
		{
			return REFNEW CPiecewiseConstantAbcdVarianceVector ();
		}

        virtual Core::INativeMatrix<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^ CreateNativeMatrix ()
		{
			return nullptr;
		}

        virtual Core::INativeCube<Cephei::QL::Models::Marketmodels::Models::IPiecewiseConstantAbcdVariance^>^ CreateNativeCube ()
		{
			return nullptr;
		}
    };
   
/*Cephei*/ } /*QL*/ } /*Models*/ } /*Marketmodels*/ } /*Models */}
